/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thread.demo;

import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author VANDH
 */
public class Radio extends Thread {

    private static int count = 0, i = 0;

    public Radio() {
    }

    @Override
    public void run() {
        synchronized ((Object) count) {
            System.out.println("Radio - I'm running here..., count=" + ++count);
            try {
                //Thread.sleep(1000);
                Scanner kb = new Scanner(System.in);
                kb.nextInt();
                if (count == 1) {
                    Radio.class.wait();
                } else {
                    Radio.class.notify();
                }
            } catch (InterruptedException ex) {
                System.out.println("Lỗi");
                Logger.getLogger(Radio.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}